// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

export { NativeStyleMetrics as StyleMetrics }

export component ScrollView {
    in-out property <length> viewport-width <=> fli.viewport-width;
    in-out property <length> viewport-height <=> fli.viewport-height;
    in-out property <length> viewport-x <=> fli.viewport-x;
    in-out property <length> viewport-y <=> fli.viewport-y;
    out property <length> visible-width <=> fli.width;
    out property <length> visible-height <=> fli.height;
    in-out property <bool> has-focus <=> native.has-focus;
    in property <bool> enabled <=> native.enabled;
    preferred-height: 100%;
    preferred-width: 100%;
    min-height: native.min-height;
    min-width: native.min-width;

    native := NativeScrollView {
        vertical-max: fli.viewport-height > fli.height ? fli.viewport-height - fli.height : 0phx;
        vertical-page-size: fli.height;

        horizontal-max: fli.viewport-width > fli.width ? fli.viewport-width - fli.width : 0phx;
        horizontal-page-size: fli.width;
    }

    fli := Flickable {
        x: native.native-padding-left;
        width: root.width - native.native-padding-left - native.native-padding-right;
        y: native.native-padding-top;
        height: root.height - native.native-padding-top - native.native-padding-bottom;

        @children
        interactive: false;
        viewport-y <=> native.vertical-value;
        viewport-x <=> native.horizontal-value;
    }
}
